#### Robustness runs
BURNIN <- 500000
MCMC <- 500000
THIN <- 100
CHAINS <- 1
VERBOSE <- 100000
SEED <- 5555

library(uds)
data(democracy1946.2000)

data.decile <- prepare.quantile(democracy)
post.decile <- mroprobit(data=data.decile,
                         sigma.mh=c(0.009, 0.065, 0.022, 0.006, 0.035,
                         0.044, 0.0024, 0.021, 0.012, 0.008),
                         save.traits = TRUE, save.perceived.traits =
                         TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                         THIN, verbose = VERBOSE, seed = 1234, 
                         chains=CHAINS, disperse=F)
save(post.decile, file="post.decile.RData")
rm(post.decile, data.decile) # free up some RAM

data.vintile <- prepare.quantile(democracy, probs=seq(.05, .95, .05))
post.vintile <- mroprobit(data=data.vintile,
                         sigma.mh=c(0.0056, 0.062, 0.016, 0.006, 0.030,
                         0.041, 0.0023, 0.022, 0.011, 0.0049),
                         save.traits = TRUE, save.perceived.traits =
                         TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                         THIN, verbose = VERBOSE, seed = 1234, 
                         chains=CHAINS, disperse=F)
save(post.vintile, file="post.vintile.RData")
rm(post.vintile, data.vintile) # free up some RAM

# Runs dropping each measure for robustness and added value checks

# no-arat
data.uds <- prepare.uds(democracy)
data.noarat <- data.uds[,2:10]
post.noarat <- mroprobit(data=data.noarat, 
                         sigma.mh=c(0.065, # blm
                                    0.022, # bollen
                                    0.006, # fh
                                    0.043, # hadenius
                                    0.044, # pacl
                                    0.0025,  # polity
                                    0.024,  # polyarchy
                                    0.012,  # prc
                                    0.01), # vanhanen
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED, 
                      chains=CHAINS, disperse=F)
save(post.noarat, file="post.noarat.RData")
rm(post.noarat, data.noarat) # free up some RAM

# no-blm
data.noblm <- data.uds[,c(1, 3:10)]
post.noblm <- mroprobit(data=data.noblm, 
                         sigma.mh=c(
                                    0.015, # arat
                                    0.022, # bollen
                                    0.006, # fh
                                    0.043, # hadenius
                                    0.044, # pacl
                                    0.0025,  # polity
                                    0.024,  # polyarchy
                                    0.012,  # prc
                                    0.01 # vanhanen
                                   ), 
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED, 
                      chains=CHAINS, disperse=F)
save(post.noblm, file="post.noblm.RData")
rm(post.noblm, data.noblm) # free up some RAM

# no-bollen
data.nobollen <- data.uds[,c(1:2, 4:10)]
post.nobollen <- mroprobit(data=data.nobollen, 
                         sigma.mh=c(0.015, # arat
                                    0.065, # blm
                                    0.006, # fh
                                    0.043, # hadenius
                                    0.044, # pacl
                                    0.0025,  # polity
                                    0.024,  # polyarchy
                                    0.012,  # prc
                                    0.01), # vanhanen
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED,
                      chains=CHAINS, disperse=F)
save(post.nobollen, file="post.nobollen.RData")
rm(post.nobollen, data.nobollen) # free up some RAM

# no-fhouse
data.nofhouse <- data.uds[,c(1:3, 5:10)]
post.nofhouse <- mroprobit(data=data.nofhouse, 
                         sigma.mh=c(0.015, # arat
                                    0.065, # blm
                                    0.022, # bollen
                                    0.043, # hadenius
                                    0.044, # pacl
                                    0.0025,  # polity
                                    0.024,  # polyarchy
                                    0.012,  # prc
                                    0.01), # vanhanen
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED,
                      chains=CHAINS, disperse=F)
save(post.nofhouse, file="post.nofhouse.RData")
rm(post.nofhouse, data.nofhouse) # free up some RAM

# no-hadenius
data.nohadenius <- data.uds[,c(1:4, 6:10)]
post.nohadenius <- mroprobit(data=data.nohadenius, 
                         sigma.mh=c(0.015, # arat
                                    0.065, # blm
                                    0.022, # bollen
                                    0.006, # fh
                                    0.044, # pacl
                                    0.0025,  # polity
                                    0.024,  # polyarchy
                                    0.012,  # prc
                                    0.01), # vanhanen
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED, 
                      chains=CHAINS, disperse=F)
save(post.nohadenius, file="post.nohadenius.RData")
rm(post.nohadenius, data.nohadenius) # free up some RAM

# no-pacl
data.nopacl <- data.uds[,c(1:5, 7:10)]
post.nopacl <- mroprobit(data=data.nopacl, 
                         sigma.mh=c(0.015, # arat
                                    0.065, # blm
                                    0.022, # bollen
                                    0.006, # fh
                                    0.043, # hadenius
                                    0.0025,  # polity
                                    0.024,  # polyarchy
                                    0.012,  # prc
                                    0.01), # vanhanen
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED,
                      chains=CHAINS, disperse=F)
save(post.nopacl, file="post.nopacl.RData")
rm(post.nopacl, data.nopacl) # free up some RAM

# no-polity
data.nopolity <- data.uds[,c(1:6, 8:10)]
post.nopolity <- mroprobit(data=data.nopolity, 
                         sigma.mh=c(0.015, # arat
                                    0.065, # blm
                                    0.022, # bollen
                                    0.006, # fh
                                    0.043, # hadenius
                                    0.044, # pacl
                                    0.024,  # polyarchy
                                    0.012,  # prc
                                    0.01), # vanhanen
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED,
                      chains=CHAINS, disperse=F)
save(post.nopolity, file="post.nopolity.RData")
rm(post.nopolity, data.nopolity) # free up some RAM

# no-polyarchy
data.nopolyarchy <- data.uds[,c(1:7, 9:10)]
post.nopolyarchy <- mroprobit(data=data.nopolyarchy, 
                         sigma.mh=c(0.015, # arat
                                    0.065, # blm
                                    0.022, # bollen
                                    0.006, # fh
                                    0.043, # hadenius
                                    0.044, # pacl
                                    0.0025,  # polity
                                    0.012,  # prc
                                    0.01), # vanhanen
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED,
                      chains=CHAINS, disperse=F)
save(post.nopolyarchy, file="post.nopolyarchy.RData")
rm(post.nopolyarchy, data.nopolyarchy) # free up some RAM

# no-prc
data.noprc <- data.uds[,c(1:8, 10)]
post.noprc <- mroprobit(data=data.noprc, 
                         sigma.mh=c(0.015, # arat
                                    0.065, # blm
                                    0.022, # bollen
                                    0.006, # fh
                                    0.043, # hadenius
                                    0.044, # pacl
                                    0.0025,  # polity
                                    0.024,  # polyarchy
                                    0.01), # vanhanen
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED,
                      chains=CHAINS, disperse=F)
save(post.noprc, file="post.noprc.RData")
rm(post.noprc, data.noprc) # free up some RAM

# no-vanhanen
data.novanhanen <- data.uds[,1:9]
post.novanhanen <- mroprobit(data=data.novanhanen, 
                         sigma.mh=c(0.015, # arat
                                    0.065, # blm
                                    0.022, # bollen
                                    0.006, # fh
                                    0.043, # hadenius
                                    0.044, # pacl
                                    0.0025,  # polity
                                    0.024,  # polyarchy
                                    0.012),  # prc
                      save.traits = TRUE, save.perceived.traits =
                      TRUE, mcmc = MCMC, burnin = BURNIN, thin =
                      THIN, verbose = VERBOSE, seed = SEED,
                      chains=CHAINS, disperse=F)
save(post.novanhanen, file="post.novanhanen.RData")
rm(post.novanhanen, data.novanhanen) # free up some RAM

rm(list=ls())
